package logic;

public class Person implements Comparable<Person>
{
	private String						name					= "";
	private long							total_dkp			= 0;
	private long							current_dkp		= 0;
	private String						comment				= new String();

	public static final long	DkpEarnDelta	= 6;

	// private java.util.Date date = new java.util.Date();
	public Person(String name)
	{
		this.name = name;
	}

	public Person(String name, long current_dkp)
	{
		this.name = name;
		this.current_dkp = current_dkp;
	}
	
	public Person(String name, String comment)
	{
		this.name = name;
		this.comment = comment;
	}

	public Person(String name, long total_dkp, long current_dkp)
	{
		this.name = name;
		this.total_dkp = total_dkp;
		this.current_dkp = current_dkp;
	}

	public Person(String name, long total_dkp, long current_dkp, String comment)
	{
		this.name = name;
		this.total_dkp = total_dkp;
		this.current_dkp = current_dkp;
		this.comment = new String(comment);
	}

	public Person(Person p)
	{
		this.name = new String(p.name);
		this.total_dkp = p.total_dkp;
		this.current_dkp = p.current_dkp;
		this.comment = new String(p.comment);
	}

	public String getNom()
	{
		return this.name;
	}

	public void setNom(String nom)
	{
		this.name = nom;
	}

	public long getTotalDkp()
	{
		return this.total_dkp;
	}

	public void setTotalDkp(long total_dkp)
	{
		this.total_dkp = total_dkp;
	}

	public long getCurrentDkp()
	{
		return this.current_dkp;
	}

	public void setCurrentDkp(long currentdkp)
	{
		this.current_dkp = currentdkp;
	}

	public void addCurrentDkp(long adddkp)
	{
		this.current_dkp += adddkp;
	}

	public String getComment()
	{
		return this.comment;
	}

	public void setComment(String comment)
	{
		this.comment = new String(comment);
	}
	
	public void addComment(String addcomment)
	{
		this.comment += addcomment;
	}

	//order by total_dkp and then alphabetical on name
	@Override
	public int compareTo(Person arg0)
	{
		int dxp_delta = (int) (arg0.total_dkp - total_dkp);
		if (dxp_delta != 0)
			return dxp_delta;
		return getNom().compareTo(arg0.getNom());
		// I probably made a great mistake here, what kind of sorting would this result into??
		// i wonder how this is called in a simple sort call.
		// Well maybe this works but actually 2 really close objects in the final right order, might have a lot of compare int
		// value difference between themselves.
		// If the caller assumes that a small int difference value means items might be closer then well this is gonna be a terrible sorting.
	}

	public String toString()
	{
		StringBuffer sb = new StringBuffer();
		sb.append(name).append(" ").append(total_dkp).append(" ").append(current_dkp).append(" ").append(comment).append(" ");
		return sb.toString();
	}
}
